package com.xinzhi.stduyspringboot.conrtoller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.mysql.cj.xdevapi.JsonArray;
import com.xinzhi.stduyspringboot.entity.User;
import com.xinzhi.stduyspringboot.service.IuserService;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.core.BoundValueOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@Controller
@RequestMapping("/user")
public class Userconrtroller {

    @Resource
    private IuserService iuserService;

    @GetMapping
    @ResponseBody
    public List<User> getUsers(){



        ExecutorService executorService = Executors.newFixedThreadPool(1000);

        Runnable runnable=() -> iuserService.queryUserList();

        for (int i = 0; i < 10000; i++) {
            executorService.execute(runnable);
        }


        return iuserService.queryUserList();
    }

/*    @Value("${user.username}")
    private String username;

    @Value("${user.hoddy}")
    private List<String> hobby;


    @GetMapping
    @ResponseBody
    public Map<String ,String> hello(){
        Map<String,String> map=new HashMap<>();
        map.put("username","zhuangsan");
        map.put("password","123");
        System.out.println(username);
        System.out.println(hobby);;
        return map;
    }*/
}
